package com.lijin.dao;

import com.lijin.entity.User;
import com.lijin.mapper.UserMapper;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

/**
 * Created by gold-jx on 2017/5/31.
 */
@Repository
public class UserDao {

    @Autowired
    private UserMapper userMapper;


    //增加，返回id
    public int insertUser(User user) {
        return userMapper.insert(user);
    }

    //增加
    public void addUser(User user) {
        userMapper.add(user);
    }

    //删除
    public void deleteUserByName(String name) {
        userMapper.deleteByName(name);
    }

    //修改
    public void updateUserByName(User user) {
        userMapper.updateById(user);
    }

    //根据名字查询
    public User findUserByName(String name) {
        return userMapper.findByName(name);
    }

    //查询所有
    public List<User> findUserAll() {
        return userMapper.findAll();
    }


}
